function [ traitScores ] = getSubpopulationCombinedTraits(subpopCodes, copyDeltas, cellLabels, traits)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

numCells = size(copyDeltas, 1);
numSites = size(copyDeltas, 2);
numTraits = size(traits, 1);
numSubpops = size(subpopCodes, 1);

traitScores = zeros(numTraits, numSubpops);

for i = 1:numSubpops
    numCellsInSubpop = 0;
    for j = 1:numCells
        if (size(findstr(subpopCodes{i}, cellLabels{j})) ~= 0)
            numCellsInSubpop = numCellsInSubpop+1;
            subpopCells(numCellsInSubpop, :) = copyDeltas(j, :);
        end
    end
    
    for k = 1:numTraits
        numWithTrait = 0;
        for j = 1:numCellsInSubpop
            has = hasCombinedTrait(subpopCells(j, :), traits(k, :));
            if (has == 1)
                numWithTrait = numWithTrait + 1;
            end
        end
        traitScores(k, i) = numWithTrait / numCellsInSubpop;
    end
end

end

